package com.sqkj.service;

import com.sqkj.dao.CommentDao;
import com.sqkj.entity.Comment;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentService {
    @Resource
    CommentDao dao;

    public List<Comment> addComment(Comment comment) {
        List<Comment> commentList = null;
        if (dao.addComment(comment) > 0) {

            commentList = dao.findByArticleId(comment.getArticleId());
            return commentList;
        } else {

            return commentList;
        }

    }

    public List<Comment> findByArticleId(int articleId) {
        return dao.findByArticleId(articleId);
    }
}
